package com.aurora.source.source.presenter;

import android.content.Context;

import com.aurora.source.base.BaseActivity;
import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.source.view.IRevampMobileView;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.util.Map;

public class RevampMobilePresenter extends BasePresenter<IRevampMobileView> {

    public RevampMobilePresenter(IRevampMobileView baseView) {
        super(baseView);
    }

    public void smsVerification(Context context, Map<String, String> params) {
        requestMethod.smsVerification(params, new SubscriberObserver<BaseBean>((Context) baseView, "数据请求中...") {
            @Override
            public void onSuccess(BaseBean baseBean) {
                if (baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onSmsVerificationSuccess(baseBean.getMsg());
                } else {
                    baseView.onSmsVerificationFail(baseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onSmsVerificationFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }

    public void resetUseMobile(BaseActivity activity, Map<String, String> params) {
        requestMethod.resetUseMobile(params, new SubscriberObserver<BaseBean>((Context) baseView, "数据请求中...") {
            @Override
            public void onSuccess(BaseBean baseBean) {
                if (baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onResetUseMobileSuccess(baseBean.getMsg());
                } else {
                    baseView.onResetUseMobileFail(baseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onResetUseMobileFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
